home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Tele / W-Z / Wait.cpt / Wait.source < prev    next >
Text File  |  1989-12-11  |  5KB  |  203 lines

  1. DEFLNG a-z
  2.  
  3. 'constants
  4.  
  5. tabch$ = CHR$(9)    'tab char
  6. SH=SYSTEM(6)        'screen height
  7. SW=SYSTEM(5)       'screen width
  8. h%=150                    'window height
  9. w%=400                   'window width
  10.  
  11. DIM SHARED IOPB%(60)    'for GetPathName
  12.  
  13. 'setup menus
  14.  
  15. MENU 1,0,1,"File"
  16. MENU 1,1,1,"Info"   :cmdkey 1,1,"I"
  17. MENU 1,2,0,"-"
  18. MENU 1,3,1,"Quit"   :cmdkey 1,3,"Q"
  19.  
  20. ON ERROR GOTO quit    'for any fatal error just abort to desktop
  21.  
  22. PgmRef%= SYSTEM(7)    'SYSTEM(7) returns file reference number
  23. CALL GetPathName (PgmRef%, PgmName$)
  24. CALL Parse (PgmName$, path$)    'separate filename and path
  25.  
  26. 'get current date and time
  27.  
  28. GOSUB getDate    'reformats date to MM/DD/YY
  29. GOSUB getTime   'gets long and "short" time formats
  30.  
  31. 'update Tabby Log file
  32.  
  33. tabbylog$ = path$+"Tabby:Tabby Log"
  34. OPEN tabbylog$ FOR APPEND AS #1
  35.     PRINT #1,today$;" ";short$;" Wait - Program Starting"
  36. CLOSE
  37.  
  38. 'Get name of next program to launch, update launch.next
  39.  
  40. launch$ = path$+"launch.next"
  41. OPEN launch$ FOR INPUT AS #1
  42. LINE INPUT #1, text$
  43. CLOSE
  44. KILL launch$    'delete the file
  45. i = INSTR(text$,",")    'find comma
  46. IF i = 0 THEN    'this is last name in file
  47.     program$ = text$
  48. ELSE
  49.     program$ = LEFT$(text$,i-1)
  50.     text$ = MID$(text$,i+1)    'remaining filenames
  51.     OPEN launch$ FOR OUTPUT AS #1    'save for next guy
  52.         PRINT #1,text$
  53.     CLOSE
  54. END IF
  55.  
  56. 'reformat time to HHMM for comparison with Tabby Events file
  57. temp$ = LEFT$(current$,2) + MID$(current$,4,2)
  58.  
  59. 'Read Events file and find out how long to wait
  60.  
  61. events$ = path$+"Tabby:Events"
  62. OPEN events$ FOR INPUT AS #1
  63. target$ = ""
  64. WHILE NOT EOF (1) AND target$ = ""
  65.     LINE INPUT #1, text$
  66.     i = INSTR(text$,tabch$)    'find first tab
  67.     start$ = MID$(text$,i+1,4)
  68.     i = INSTR(i+1,text$,tabch$)    'find next tab
  69.     finish$ = MID$(text$,i+1,4)
  70.     IF start$ <= temp$ AND temp$ < finish$ THEN
  71.         'reformat target time to HH:MM:00
  72.         target$ = LEFT$(finish$,2)+":"+RIGHT$(finish$,2)+":00"    
  73.     END IF
  74. WEND
  75. CLOSE
  76.  
  77. 'check target event and wait ONLY if we found one...
  78.  
  79. IF target$ <> "" THEN    'we found one
  80.     'setup to handle Cmd-I (Info) and Cmd-Q (Quit)
  81.     ON MENU GOSUB handlemenu    
  82.     MENU ON
  83.     temp$ = TIME$
  84.     WHILE temp$ < target$    'loop until end of timed event
  85.         temp$ = TIME$
  86.     WEND
  87. END IF
  88.  
  89. 'get current date and time
  90.  
  91. GOSUB getDate
  92. GOSUB getTime
  93.  
  94. 'update Callerlog
  95.  
  96. callerlog$ = path$+"Callerlog"
  97. OPEN callerlog$ FOR APPEND AS #1
  98.      PRINT #1,"Launching <";path$;program$;"> on ";today$;" at ";current$
  99. CLOSE
  100.  
  101. 'update Tabby Log
  102.  
  103. tabbylog$ = path$+"Tabby:Tabby Log"
  104. OPEN tabbylog$ FOR APPEND AS #1
  105.     PRINT #1,today$;" ";short$;" Wait - Program Ending"
  106. CLOSE
  107.  
  108. Transfer program$    'do launch.next and...
  109.  
  110. quit:
  111. 'we're all done (or an error occured) so lets get out of here!
  112. CLOSE    'any open files
  113. END    'and then quit back to the desktop
  114.  
  115. '----------------------- Subroutines -------------------------
  116. getDate:
  117.     today$ = DATE$    'format is MM-DD-YYYY
  118.     'change format to MM/DD/YY
  119.     today$ = LEFT$(today$,2)+"/"+MID$(today$,4,2)+"/"+RIGHT$(today$,2)
  120. RETURN
  121.  
  122. '-----------------------
  123. getTime:
  124.     'gets current time in long and short (H:MM:SS) formats
  125.     current$ = TIME$    'format is HH:MM:SS
  126.     short$ = current$     'temporary time string
  127.     IF LEFT$(short$,1) = "0" THEN    'if hour is less than 10 then
  128.         short$ = MID$(short$,2)    'reformat to (H:MM:SS)
  129.     END IF
  130. RETURN
  131.  
  132. '-----------------------
  133. handlemenu:
  134.     MenuID= MENU(0)
  135.     MenuItem= MENU(1)
  136.     IF MenuID = 1 THEN
  137.         IF MenuItem = 1 THEN
  138.             GOSUB showinfo
  139.         ELSEIF MenuItem = 3 THEN
  140.             GOTO quit
  141.         END IF    'ignore all other cases
  142.     END IF
  143.     MENU
  144. RETURN
  145.  
  146. '-----------------------
  147. showinfo:
  148. WINDOW 10,,((SW-w%)/2,(SH-h%)/3)-((SW-w%)/2+w%,(SH-h%)/3+h%),2
  149. text$="Wait 1.0"
  150. TEXTFONT 0
  151. MOVETO  (WINDOW(2)-WIDTH(text$))\2,20    'center title$
  152. DrawText text$:PRINT
  153. TEXTFONT 3
  154. text$ = "A Tabby 2.1 Utility. Freeware by Mark J. Smith, 1989"
  155. MOVETO  (WINDOW(2)-WIDTH(text$))\2,45    'center text$
  156. DrawText text$:PRINT
  157. text$ = "Waiting until: " + target$
  158. MOVETO  (WINDOW(2)-WIDTH(text$))\2,75    'center text$
  159. DrawText text$:PRINT
  160. text$ = "Next program to launch: " + program$
  161. MOVETO  (WINDOW(2)-WIDTH(text$))\2,100    'center text$
  162. DrawText text$:PRINT
  163. text$ = "Click in window to close"
  164. MOVETO  (WINDOW(2)-WIDTH(text$))\2,125    'center text$
  165. DrawText text$:PRINT
  166. m%=MOUSE(0)
  167. WHILE m%=0 OR m%=-1:m%=MOUSE(0):WEND
  168. WINDOW CLOSE 10
  169. RETURN
  170.  
  171. '----------------------- Sub-Programs -------------------------
  172. '    Gets the full path name of a file given the file reference
  173. '    number.
  174. '
  175. SUB GetPathName (ref%,path$) STATIC
  176.     filename$="" : Folder$=""
  177.     GetFCBInfo IOPB%(0),filename$,ref%
  178.     path$=filename$
  179.     DirID&=IOPB%(29)*65536&+IOPB%(30)
  180.     VRefNum%=IOPB%(26)
  181.     WHILE DirID&<>1
  182.         GetCatInfo IOPB%(0),Folder$,DirID&,VRefNum%
  183.         path$=Folder$+":"+path$
  184.         DirID&=IOPB%(50)*65536&+IOPB%(51)
  185.     WEND
  186. END SUB
  187.  
  188. '----------------------------------------------------------------
  189. SUB Parse (filename$,path$) STATIC
  190. index%=1
  191.     WHILE index% '<>0
  192.         last%=index%
  193.         index%=INSTR(index%+1,filename$,":")
  194.     WEND
  195.     IF last%=1 THEN  'there was no path
  196.         path$=""
  197.     ELSE             'divide filename$ into path$ and filename$
  198.         path$=LEFT$(filename$,last%)
  199.         filename$=RIGHT$(filename$,LEN(filename$)-last%)
  200.     END IF
  201. END SUB
  202.  
  203.